﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserEdit.aspx.cs" Inherits="CNVP.JShop.Web.Admin.UserEdit" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="IE=7" http-equiv="X-UA-Compatible" />
    <link href="CSS/Edit.css" rel="stylesheet" type="text/css" />
    <script src="../Scripts/jquery.js" type="text/javascript"></script>
    <script src="../Scripts/common.js" type="text/javascript"></script>
    <script src="../Scripts/Users.js" type="text/javascript"></script>
    <script type="text/javascript">
         if(<%=id %>==0)
         {
             $(function () {
                 $("#btUp").click(function () {
                     var $txtUserName = $("#txtUserName");
                     if ($txtUserName.val() == "") {
                         alert("请输入会员账户！");
                         $txtUserName.focus();
                         return false;
                     }
                     if (IsUserNameExists($txtUserName.val())==2) {
                        alert("不允许使用该用户名，请重新填写！");
                        $txtUserName.focus();
                         return false;
                     }
                     else if (IsUserNameExists($txtUserName.val())==1) {
                         alert("该会员账户已存在，请重新填写！");
                         $txtUserName.focus();
                         return false;
                     }
                     var $txtPwd1 = $("#txtPwd1");
                     if ($txtPwd1.val() == "") {
                         alert("请输入新密码！");
                         $txtPwd1.focus();
                         return false;
                     }
                     var $txtPwd2 = $("#txtPwd2");
                     if ($txtPwd2.val() == "") {
                         alert("请输入确认新密码！");
                         $txtPwd2.focus();
                         return false;
                     }
                     if ($txtPwd1.val() != $txtPwd2.val()) {
                         alert("新密码与确认新密码不相同！");
                         $txtPwd2.focus();
                         return false;
                     }
                     var $ddlUserLevelID=$("#ddlUserLevelID");
                     if ($ddlUserLevelID.val() == "0") {
                         alert("请选择会员等级！");
                         $ddlUserLevelID.focus();
                         return false;
                     }
                 });
             })

             function IsUserName() {
                 var UserNameValue=$("#txtUserName").val();
                 if (IsUserNameExists(UserNameValue)==2) {
                    $("#UserName").html("<font color='#ff0000'>不允许使用该用户名，请重新填写．</font>");
                 }
                 else if (IsUserNameExists(UserNameValue)==1) {
                     $("#UserName").html("<font color='#ff0000'>该会员账户已存在，请重新填写．</font>");
                 }
                 else {
                     $("#UserName").html("<font color='#00ff00'>会员账户输入正确．</font>");
                     //判断是否是邮箱
                     var $txtEmail=$("#txtEmail");
                    if (IsValidEMail(UserNameValue)) {
                       document.getElementById("txtEmail").value = UserNameValue;
                    }
                 }
             }
         }
         else
         {
            $(function(){
                $("#btUp").click(function(){
                    var $ddlUserLevelID=$("#ddlUserLevelID");
                     if ($ddlUserLevelID.val() == "0") {
                         alert("请选择会员等级！");
                         $ddlUserLevelID.focus();
                         return false;
                     }
                })
            })
         }
    </script>
</head>
<body onload="ProvinceChange()">
    <form id="form1" runat="server" autocomplete="off">
        <div class="Content">
            <table width="100%" border="0" cellspacing="0" cellpadding="0" class="cell">
             <tr>
                <td class="cell_group">
                    <img src="Images/ListIconTitle.jpg" alt="" />&nbsp;您的位置：<a href="UserList.aspx">会员管理</a><asp:Label ID="lbTitle" runat="server"></asp:Label>
                </td>
            </tr>
            </table>
                    <table border="0" cellpadding="0" cellspacing="0" class="division">
                        <tr>
                            <th>
                                 会员账户:</th>
                            <td>
                                <asp:TextBox ID="txtUserName" runat="server" />
                                <div id="UserName"></div>
                                <asp:Label ID="lbtxtUserName" runat="server" ></asp:Label>
                                </td>
                        </tr>
                        <tr id="Pwd1" runat="server">
                            <th>
                                 密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码:</th>
                            <td>
                                <asp:TextBox ID="txtPwd1" runat="server" TextMode="Password"  />
                                </td>
                        </tr>
                        <tr id="Pwd2" runat="server">
                            <th>
                                 确认密码:</th>
                            <td>
                                <asp:TextBox ID="txtPwd2" runat="server" TextMode="Password"  />
                                </td>
                        </tr>
                        <tr>
                            <th>
                                 会员级别:</th>
                            <td>
                                <asp:DropDownList ID="ddlUserLevelID" runat="server" Width="150px">
                                <asp:ListItem Value ="0">--请选择--</asp:ListItem>
                                </asp:DropDownList>
                                </td>
                        </tr>
                        <tr>
                            <th>
                                  Email:</th>
                            <td>
                                <asp:TextBox ID="txtEmail" runat="server"  />
                                </td>
                        </tr>
                        <tr>
                            <th>
                                手机：</th>
                            <td>
                                <asp:TextBox ID="txtMobilePhone" runat="server" MaxLength="50"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                省区：</th>
                            <td>
                                <asp:DropDownList ID="ddlProvince" runat="server">
                                <asp:ListItem Value="0">--请选择--</asp:ListItem>
                                </asp:DropDownList>
                                <span id="selectCity"></span>
                                <span id="selectArea"></span>
                         
                                </td>
                        </tr>
                        <tr>
                            <th>
                                地址：</th>
                            <td>
                                <asp:TextBox ID="txtGetAddress" runat="server" Width="558px" MaxLength="100"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                 其他信息:</th>
                            <td>
                                <asp:TextBox ID="txtOtherText" runat="server" Height="50px" 
                                    TextMode="MultiLine" Width="558px"></asp:TextBox>
                                </td>
                        </tr>
                         <tr id="AddTime" runat="server">
                            <th>
                                 注册时间:</th>
                            <td>
                               <asp:Label ID="lbAddTime" runat="server"></asp:Label>
                                </td>
                        </tr>
                        <tr  id="AddIP" runat="server">
                            <th>
                                 注册IP:</th>
                            <td>
                                <asp:Label ID="lbAddIP" runat="server"></asp:Label>
                                </td>
                        </tr>
                        <tr  id="EndLoginTime" runat="server">
                            <th>
                                 上次登陆时间:</th>
                            <td>
                                <asp:Label ID="lbEndLoginTime" runat="server"></asp:Label>
                                </td>
                        </tr>
                         <tr  id="EndLoginIP" runat="server">
                            <th>
                                 上次登陆IP:</th>
                            <td>
                                <asp:Label ID="lbEndLoginIP" runat="server"></asp:Label>
                                </td>
                        </tr>
                        <tr  id="LoginNum" runat="server">
                            <th>
                                 登录次数:</th>
                            <td>
                                <asp:Label ID="lbLoginNum" runat="server"></asp:Label>
                                </td>
                        </tr>
                    </table>
            <div class="EditBtn">  
            <asp:Button ID="btUp" runat="server" Text="提交" OnClick="btUp_Click" />
                                <input type="button" value="取消" onclick="javascript:history.go(-1)" />
                                </div>
    </div>
    </form>
    <script type="text/javascript">
            function ProvinceChange() {
            var ddlProvince = document.getElementById("<%=ddlProvince.ClientID %>");
            var selectCity = document.getElementById("selectCity");
            selectCity.innerHTML = GetAjaxResponse("../Admin/CommonWindows/AjaxCity.aspx?Type=ProvinceID&Code=" + ddlProvince.value);
            if(<%=Province %>!="0" && <%=City %> !="0")
            {
                if(ddlProvince.value==<%=Province %>)
                {
                    var ListCity = document.getElementById("ListCity");
                    ListCity.value=<%=City %>;
                }
            }
            CityChange();
            
        }
        //选择市时引发的动作
        function CityChange() {
            var ListCity = document.getElementById("ListCity");
            var selectArea = document.getElementById("selectArea");
            selectArea.innerHTML = GetAjaxResponse("../Admin/CommonWindows/AjaxCity.aspx?Type=CityID&Code=" + ListCity.value);
            if(<%=City %>!="0" && <%=Area %> !="0")
            {
                if(ListCity.value==<%=City %>)
                {
                    var ListArea = document.getElementById("ListArea");
                    ListArea.value=<%=Area %>;
                }
            }
        }
</script>
</body>
</html>
